#include <iostream>
#include <string>
#include <algorithm>


using namespace std;

#define int long long
const int N = 1e5 + 10;
int q[N];
int a[N], b[N];
void solve()
{
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> q[i];
	sort(q, q + n);
	int ans = 0;
	int i;
	for (i = n - 1; k; k--, i -= 2)
	{
		ans += q[i - 1] / q[i];
	}
	for (int j = 0; j <= i; j++)
		ans += q[j];
	cout << ans << endl;
}

signed main()
{
	int t;
	cin >> t;
	while (t--)
		solve();
	return 0;
}